<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body>

<div id="container"  style="width:800px;height:600px;border:1px solid grey"></div>

<script src="vs/loader.js"></script>
<script>
    
 require.config({
    paths: { 'vs': 'vs' }});
    require(['vs/editor/editor.main'], function() { 
            //创建编辑框
            var editor = monaco.editor.create(
            document.getElementById('container'),
            { 
                value: ['function x() {','\tconsole.log("Hello world!");','}'].join('\n'),
                language:"javascript"
            });
            //监听编辑框内容变化
            editor.onDidChangeModelContent((e) => { 
            console.log(e)   
            });
            //获取编辑框内容
            editor.getValue();
            //设置编辑框内容 editor.setValue("function func(){\nconsole.log("hello"\n}");
    });

</script>
</body>
</html>